package Text22;

import java.util.*;
public class Main {
    public static int N = 110;
    public static int[] v = new int[N];
    public static int[] w = new int[N];
    public static int[] s = new int[N];
    public static int[][] f = new int[N][N];

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int m = scan.nextInt();
        for (int i = 1; i <= n; i++) {
            v[i] = scan.nextInt();
            w[i] = scan.nextInt();
            s[i] = scan.nextInt();
        }
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= m; j++) {
                for (int k = 0; k <= s[i] && k * v[i] <= j; k++) {
                 f[i][j]=Math.max(f[i][j],f[i-1][j-k*v[i]]+k*w[i]);
                }
            }
        }
        System.out.println(f[n][m]);
    }
}

